<?php


namespace App\Dao;

use App\Model\NoticeEmployer;

class NoticeEmployerDao extends AbstractDao
{
    /**
     * @param array $where
     * @return \Hyperf\Database\Model\Builder
     */
    public function where(array $where): \Hyperf\Database\Model\Builder
    {
        $query = NoticeEmployer::query();
        foreach ($where as $field => $value) {
            switch ($field) {
                case 'employer_ids':
                    $query->whereIn('employer_id', $value);
                    break;
                case 'created_at_gt':
                    $query->where('created_at', '>', $value);
                    break;
                default:
                    if (is_array($value)) {
                        $query->where($field, $value[0], $value[1]);
                    } else {
                        $query->where($field, $value);
                    }
            }
        }
        return $query;
    }
}